import React from "react"
import ReactEcharts from 'echarts-for-react'

export default class Bar extends React.Component {

  state = {
    sales: [5, 20, 36, 10, 10, 20],
    stores: [6, 10, 25, 20, 15, 10], 
  }

  // update = () => {
  //   this.setState(state => ({
  //     sales: state.sales.map(sale => sale + 1),
  //     stores: state.stores.reduce((pre, store) => {
  //       pre.push(store-1)
  //       return pre
  //     }, []),
  //   }))
  // }

  /*
  返回折线图的配置对象
   */
  getOption = (sales, stores) => {
    return {
      tooltip: {},
      legend: {
        data:['访问量']
      },
      xAxis: {
        data: ["七月","八月","九月","十月","十一月","十二月"]
      },
      yAxis: {},
      series: [{
        name: '访问量',
        type: 'line',
        data: sales
      }]
    }
  }

  render() {
    const {sales, stores} = this.state
    return (
      <div>
          <ReactEcharts option={this.getOption(sales, stores)} style={{width:850, height:350, margin:10}}/>
      </div>
    )
  }
}